package com.zk.algorithm.dynamicprogramming;

import com.zk.algorithm.Utils;
import com.zk.algorithm.annotation.Easy;
import com.zk.algorithm.annotation.LeetCodeExplore;

/**
 * 跳台阶
 *
 * @author zk
 */
@LeetCodeExplore
@Easy
public class ClimbingStairs {

    public int climbStairs(int n) {
        if (n <= 1) {
            return 1;
        } else if (n == 2) {
            return 2;
        }

        int n1 = 1;
        int n2 = 2;

        int ans = 0;
        for (int i = 3; i <= n; i++) {
            ans = n1 + n2;

            n1 = n2;
            n2 = ans;
        }

        return ans;
    }

    public static void main(String...args) {
        Utils.println(new ClimbingStairs().climbStairs(3));
    }

}
